import 'package:bilibili/pages/login/login_bottom.dart';
import 'package:bilibili/pages/login/login_header.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:bilibili/core/extension/int_extension.dart';

class RegisterContent extends StatefulWidget {
  const RegisterContent({Key? key}) : super(key: key);

  @override
  _RegisterContentState createState() => _RegisterContentState();
}

class _RegisterContentState extends State<RegisterContent> {
  FocusNode focusNode = FocusNode();
  bool accDisabled = true;
  bool pasDisabled = true;
  bool disabled = true;
  int imageNum = 1;
  String account = "";
  String password = "";
  void getAccount(String value) {
    value.isEmpty?accDisabled=true:accDisabled=false;
    if(accDisabled||pasDisabled) setState(() => disabled=true);
    else setState(() => disabled=false);
    account = value;
  }
  void getPassword(String value) {
    value.isEmpty?pasDisabled=true:pasDisabled=false;
    if(accDisabled||pasDisabled) setState(() => disabled=true);
    else setState(() => disabled = false);
    password = value;
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    focusNode.addListener(() {
      if(focusNode.hasFocus) setState(() {imageNum = 2;});
      else setState(() {imageNum = 1;});
    });

  }
  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    focusNode.dispose();
  }
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        LoginHeader(context, imageNum, focusNode, getAccount, getPassword).buildLoginHeader(isReg: true),
        SizedBox(height: 50.px,),
        LoginBottom(context, account, password).buildLoginBottom(isReg: true, disabled: disabled)
      ],
    );
  }


}
